#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;

void solve()
{
	int n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;
	for (int i = 0; i < n; i++)
	{
		if (s1[i] == '1')
		{
			bool flag = false;
			for (int j = i - 1; j >= 0; j -= 2)
			{
				if (s2[j] == '0')
				{
					s2[j] = '1';
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				for (int j = i + 1; j < n; j += 2)
				{
					if (s2[j] == '0')
					{
						s2[j] = '1';
						flag = true;
						break;
					}
				}
			}
			if (!flag)
			{
				cout << "no" << '\n';
				return;
			}
		}
	}
	cout << "yes" << '\n';
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	cin >> _;
	while (_--)
	{
		solve();
	}
	return 0;
}